#pragma once

#include "AsyncLibDef.h"

namespace AsyncLib
{

class CThreadpoolWork
{
public:
	CThreadpoolWork();
	~CThreadpoolWork();

	void Init();
	void Stop();
	void Exit();
	void PostTask(std::function<void()>&& fnTask);

private:
	void ThreadProc();

	std::mutex m_mutex;
	std::condition_variable m_condVar;
	std::deque<std::function<void()>> m_deqTasks;
	std::vector<pthread_t> m_vecThreads;
	UINT m_nMinThreads;
	UINT m_nMaxThreads;
	UINT m_nIdleThreads;
};

} // namespace AsyncLib
